<?php

namespace Database\Seeders;

use App\Models\Master;
use App\Models\Video;
use Illuminate\Database\Seeder;

class MasterSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $masters = Master::factory()
            ->count(20)
            ->create();

        $videos = Video::factory()
            ->count(5)
            ->create();

        foreach($masters as $master) {
            $master->videos()->attach($videos->random(rand(1, 3))->pluck('id')->toArray());
        }
    }
}
